const defaultState = {
  initCartData: [], // 所有的数据

}

export default (state = defaultState, action) => {
  // 拷贝数据  修改数据  返回确定数据
  const newState = JSON.parse(JSON.stringify(state));
  if (action.type === 'get_cart_data') {
    newState.initCartData = action.data
  }

  if (action.type === 'to_cart') {

  }

  if (action.type === 'add_cart') {
    newState.initCartData[action.index].count ++;
  }

  if (action.type === 'remove_cart') {
    newState.initCartData[action.index].count ++;
  }


  return newState;
}